/************************************************************************

								Heroes IV
					  Copyright 2001, The 3DO Company

	------------------------------------------------------------------
  					       library.cpp

	$Header: /game/library.cpp $

	$NoKeywords: $

 ************************************************************************/
// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "library.h"

#include "adv_object_type.h"
#include "ai_value.h"
#include "object_registration.h"

static t_object_registration<t_library> k_registration( k_adv_object_school, 
														k_school_library );

static const int k_skill_cost = 2000;

// -------------------------------------------------------------
// Selected hero gains skill from visiting a war institute
// -------------------------------------------------------------
t_library::t_library( std::string const& source )
	: t_war_institute( ::get_skill_set(true, true, true, false), source )
{
}

// -------------------------------------------------------------
// -------------------------------------------------------------
float t_library::ai_value( t_adventure_ai const& ai, t_creature_array const& army, int move_cost ) const
{
	if (!player_can_afford( &army, k_skill_cost )) 
		return 0.0f;
	
	return 
		( ai_average_of_upgradable_skill_value( k_skill_cost, k_skill_life_magic, k_skill_nature_magic, &army, this )
		 + ai_average_of_upgradable_skill_value( k_skill_cost, k_skill_healing_magic, k_skill_recruitment, &army, this ) ) 
		 / 2;
}

// -------------------------------------------------------------
// -------------------------------------------------------------
float t_library::ai_value_to_hero( t_hero const* hero, t_creature_array const* array ) const
{
	return	
		( ai_average_of_upgradable_skill_value( hero, k_skill_cost, k_skill_life_magic, k_skill_nature_magic, array, this )
			+ ai_average_of_upgradable_skill_value( hero, k_skill_cost, k_skill_healing_magic, k_skill_recruitment, array, this ) ) 
			/ 2;
}
